function format(result = 'yyyy-MM-dd hh:mm:ss') {

    if (/(y+)/.test(result)) {
        let $1 = RegExp.$1;
        result = result.replace($1, this.getFullYear().toString().substring(4 - $1.length));
    }

    let pairs = {
        'M+': this.getMonth() + 1,
        'd+': this.getDate(),
        'h+': this.getHours(),
        'm+': this.getMinutes(),
        's+': this.getSeconds(),
        'Q+': Math.floor((this.getMonth() + 3) / 3),
        'S+': this.getMilliseconds()
    };

    for (let key in pairs) {
        if (new RegExp(`(${key})`).test(result)) {
            let item = pairs[key].toString();
            let $1 = RegExp.$1;
            let length = $1.length;

            result = result.replace($1, length === 1 ? item : item.padStart(length, 0));
        }
    }

    return result;
}



Date.prototype.format = format;